package backup;

public class BackupWorker extends Thread{
	
	private String username;
	private String password;
	private String localDir;
	private long interval;
	
	private SyncMachine machine;
	
	public BackupWorker(String username, String password, String localDir, long interval) {
		this.username = username;
		this.password = password;
		this.localDir = localDir;
		this.interval = interval;
		machine = new SyncMachine();
	}
	
	@Override
	public void run() {
		while (true) {
			machine.setCloud(username, password);
			machine.setLocal(localDir);
			machine.sync();
			try {
				Thread.sleep(interval);
			} catch (InterruptedException e) {
				e.printStackTrace();
			}
		}
	}
}
